{% extends 'home.html' %}
{% block content-title %}
    <title>查看所有书籍</title>
{% endblock %}
{% block content_main %}
    <style>
        .book_image {
            height: 150px;
        }

        .w100 {
            width: 100px;
        }

        .text_center {
            text-align: center;
        }

        .book_desc {
            width: 450px;
            text-align: left;
            font-family: "Microsoft YaHei Light";
        }

        td, th {
            text-align: center;
            vertical-align: middle !important;
        }
    </style>
    {% block book_title %}
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">读者界面</h3>
        </div>
    {% endblock %}
        {% block book_all %}
            <div class="panel-body">
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>书籍封面</th>
                        <th>详细信息</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for book_obj in book_data %}
                        <tr>
                            <td class="w100">{{ forloop.counter }}</td>
                            <td rowspan="1" class="w100">
                                <img src="{{ book_obj.image }}" alt="{{ book_obj.name }}" class="book_image">
                            </td>
                            <td class="book_desc">
                                <h4><b>{{ book_obj.name }}</b></h4>
                                <h5>
                                    【
                                    {% for author in book_obj.author.all %}
                                        <span>{{ author.name }}</span>
                                    {% endfor %}
                                    】
                                    <span>|&emsp;{{ book_obj.word_count }}万字</span>
                                    <span>|&ensp;{{ book_obj.register_date|date:"Y/m/d" }}</span>
                                </h5>
                                <h6>{{ book_obj.desc }}</h6>
                            </td>
                            <td rowspan="1" class="w100">
                                <a href="{{ book_obj.url }}" type="button" class="btn btn-success">查看详细</a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
                <div class="text_center">{{ page_html|safe }}</div>
            </div>
        {% endblock %}
    </div>
{% endblock %}